<?php
namespace app\admin\validate;

use think\Validate;

class Main extends Validate{
    public function fieldvalidate($id = 0)
    {
        if($id){
            $fields = $this->scene['edit'];
        }else{
            $fields = $this->scene['add'];
        }
        $arr = [];
        $rule = $this->rule;
        foreach($fields as $v){
            if(isset($rule[$v]) && preg_match('/require/', $rule[$v])){
                $arr[$v] = true;
            }
        }
        return $arr;
    }
}